.class Lcom/instagram/android/b/d;
.super Ljava/lang/Object;
.source "AnalyticsStorage.java"


# instance fields
.field private final a:Ljava/io/File;

.field private final b:Lcom/fasterxml/jackson/databind/ObjectMapper;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter

    .prologue
    .line 32
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 33
    invoke-static {p1}, Lcom/instagram/android/b/f;->a(Landroid/content/Context;)Ljava/io/File;

    move-result-object v0

    iput-object v0, p0, Lcom/instagram/android/b/d;->a:Ljava/io/File;

    .line 34
    invoke-static {}, Lcom/instagram/android/b/d;->a()Lcom/fasterxml/jackson/databind/ObjectMapper;

    move-result-object v0

    iput-object v0, p0, Lcom/instagram/android/b/d;->b:Lcom/fasterxml/jackson/databind/ObjectMapper;

    .line 35
    return-void
.end method

.method static a()Lcom/fasterxml/jackson/databind/ObjectMapper;
    .locals 4

    .prologue
    .line 64
    new-instance v0, Lcom/fasterxml/jackson/databind/ObjectMapper;

    invoke-direct {v0}, Lcom/fasterxml/jackson/databind/ObjectMapper;-><init>()V

    .line 65
    new-instance v1, Lcom/fasterxml/jackson/databind/module/SimpleModule;

    invoke-direct {v1}, Lcom/fasterxml/jackson/databind/module/SimpleModule;-><init>()V

    .line 66
    const-class v2, Lcom/instagram/android/b/b;

    new-instance v3, Lcom/instagram/android/b/c;

    invoke-direct {v3}, Lcom/instagram/android/b/c;-><init>()V

    invoke-virtual {v1, v2, v3}, Lcom/fasterxml/jackson/databind/module/SimpleModule;->addSerializer(Ljava/lang/Class;Lcom/fasterxml/jackson/databind/JsonSerializer;)Lcom/fasterxml/jackson/databind/module/SimpleModule;

    .line 67
    const-class v2, Lcom/instagram/b/b;

    new-instance v3, Lcom/instagram/android/b/a;

    invoke-direct {v3}, Lcom/instagram/android/b/a;-><init>()V

    invoke-virtual {v1, v2, v3}, Lcom/fasterxml/jackson/databind/module/SimpleModule;->addSerializer(Ljava/lang/Class;Lcom/fasterxml/jackson/databind/JsonSerializer;)Lcom/fasterxml/jackson/databind/module/SimpleModule;

    .line 68
    invoke-virtual {v0, v1}, Lcom/fasterxml/jackson/databind/ObjectMapper;->registerModule(Lcom/fasterxml/jackson/databind/Module;)Lcom/fasterxml/jackson/databind/ObjectMapper;

    .line 69
    return-object v0
.end method

.method private b()V
    .locals 2

    .prologue
    .line 56
    iget-object v0, p0, Lcom/instagram/android/b/d;->a:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v0

    if-nez v0, :cond_0

    .line 57
    iget-object v0, p0, Lcom/instagram/android/b/d;->a:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->mkdir()Z

    move-result v0

    if-nez v0, :cond_0

    .line 58
    const-string v0, "AnalyticsStorage"

    const-string v1, "Unable to open analytics storage."

    invoke-static {v0, v1}, Lcom/facebook/e/a/a;->e(Ljava/lang/String;Ljava/lang/String;)V

    .line 61
    :cond_0
    return-void
.end method


# virtual methods
.method public a(Lcom/instagram/android/b/b;)Ljava/io/File;
    .locals 5
    .parameter

    .prologue
    .line 38
    invoke-direct {p0}, Lcom/instagram/android/b/d;->b()V

    .line 40
    new-instance v0, Ljava/io/File;

    iget-object v1, p0, Lcom/instagram/android/b/d;->a:Ljava/io/File;

    invoke-static {p1}, Lcom/instagram/android/b/f;->a(Lcom/instagram/android/b/b;)Ljava/lang/String;

    move-result-object v2

    invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 42
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 43
    invoke-virtual {v0}, Ljava/io/File;->delete()Z

    move-result v1

    .line 44
    if-nez v1, :cond_0

    .line 45
    const-string v1, "AnalyticsStorage"

    const-string v2, "File %s was not deleted"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object v0, v3, v4

    invoke-static {v2, v3}, Lcom/facebook/c/i/c;->a(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/facebook/e/a/a;->d(Ljava/lang/String;Ljava/lang/String;)V

    .line 49
    :cond_0
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v1

    invoke-virtual {p1, v1, v2}, Lcom/instagram/android/b/b;->a(J)V

    .line 50
    iget-object v1, p0, Lcom/instagram/android/b/d;->b:Lcom/fasterxml/jackson/databind/ObjectMapper;

    invoke-virtual {v1, v0, p1}, Lcom/fasterxml/jackson/databind/ObjectMapper;->writeValue(Ljava/io/File;Ljava/lang/Object;)V

    .line 52
    return-object v0
.end method
